/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.cloud.base.util.expression;
import fr.expression4j.core.Expression;
import fr.expression4j.core.Parameters;
import fr.expression4j.core.exception.EvalException;
import fr.expression4j.core.exception.ParsingException;
import fr.expression4j.factory.ExpressionFactory;
import fr.expression4j.factory.NumberFactory;
/**
 * @project-name:standard-cloud
 * @package-name:com.hyts.cloud.base.util.expression
 * @author:LiBo/Alex
 * @create-date:2020-06-29 21:49
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description:
 */
public class TestPredefined {

    /**
     * @param args
     */
    public static void main(String[] args) {
//		abs(x)		绝对值
//		acos(x)		反余弦值
//		asin(x)		反正弦值
//		atan(x)		反正切
//		ceil(x)		向上取整
//		cos(x)		余弦
//		cosh(x)		双曲余弦
//		exp(x)		e的x次幂
//		floor(x)	向下取整
//		log(x)		对数
//		random()	随机数
//		sin(x)		正弦
//		sinh(x)		双曲正弦
//		sqrt(x)		平方根
//		tan(x)		正切
        try {
            Expression exp1 = ExpressionFactory.createExpression("f()=random()");
            double val = exp1.evaluate(null).getRealValue();
            System.out.println("result:" + val);
        } catch (ParsingException e) {
            e.printStackTrace();
        } catch (EvalException e) {
            e.printStackTrace();
        }
    }
}
